package cn.dapeng.ticket;

import java.util.ArrayList;
import java.util.List;


public class Ticket_Demo04 {

    static final List<String> tickets = new ArrayList<>();

    static {
        for (int i = 0; i < Constant.TICKET_NUM; i++) {
            tickets.add("ticket-num:" + i);
        }
    }

    public static void main(String[] args) {

        for (int i = 0; i < Constant.THREAD_NUM; i++) {
            new Thread(() -> {
                synchronized (Ticket_Demo04.class) {
                    while (!tickets.isEmpty()) {
                        System.out.println(tickets.remove(0));
                    }
                }
            }).start();
        }
    }

}
